
AddComponentPostInit("reticule", function(Reticule)
    local oldDestroyReticule = Reticule.DestroyReticule
    function Reticule:DestroyReticule(...)
        if self.inst.i26_reticule then
            self.inst.i26_reticule:Remove()
            self.inst.i26_reticule = nil
        end
        return oldDestroyReticule(self, ...)
    end

    local oldUpdateColour = Reticule.UpdateColour
    function Reticule:UpdateColour(...)
        if self.inst.i26_reticule then
            local alpha_mod = (self.targetpos ~= nil and self.fadealpha * self.blipalpha) or self.blipalpha
            local r, g, b, alpha = self.currentcolour[1], self.currentcolour[2], self.currentcolour[3], self.currentcolour[4] * alpha_mod
        
            self.inst.i26_reticule.AnimState:SetMultColour(r, g, b, alpha)
        
            local reticule_children = self.inst.i26_reticule.children 
            if reticule_children then
                for reticule_child in pairs(reticule_children) do
                    reticule_child.AnimState:SetMultColour(r, g, b, alpha)
                end
            end
        end
        return oldUpdateColour(self, ...)
    end

    Reticule.OnRemoveFromEntity = Reticule.DestroyReticule
    Reticule.OnRemoveEntity = Reticule.DestroyReticule
end)